package cn.keniykey.mc.landterritory.command;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Nullable;

import org.bukkit.command.CommandSender;

public abstract class AbCommandBase {
	protected static final List<String> emptylist = new ArrayList<>(0);
	private final String instruction;
	private final String permission;
	private final boolean mustplayer;
	
	protected AbCommandBase(String instruction,@Nullable String permission,boolean mustplayer) {
		this.instruction = (instruction ==  null ? instruction : instruction.toLowerCase());
		this.permission = permission;
		this.mustplayer = mustplayer;
	}
	
	public final String getInstruction() {
		return this.instruction;
	}
	public final String getPermission() {
		return this.permission;
	}
	public final boolean isMustPlayer() {
		return this.mustplayer;
	}
	
	public boolean execute(CommandSender sender,List<String> parameter) {
		sender.sendMessage("指令已执行");
		return true;
	}
	@Nullable
	public List<String> prompt(CommandSender sender,List<String> parameter) {
		return null;
	}
	@Nullable
	public String usage() {
		return null;
	}
	
	@Override
	public boolean equals(Object obj) {
		if (obj == null) return false;
		if (obj == this) return true;
		if (!(obj instanceof AbCommandBase)) return false;
		return ((AbCommandBase)obj).instruction.equals(this.instruction);
	}
	@Override
	public int hashCode() {
		return this.instruction.hashCode();
	}
}